package cz.cuni.amis.episodic.bayes.experiment;

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;

import cz.cuni.amis.episodic.bayes.utils.MemChart;
import cz.cuni.amis.episodic.dybanem.DBN;
import cz.cuni.amis.episodic.dybanem.GoogleUtils;
import cz.cuni.amis.episodic.dybanem.ProbabilityUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.ArrayUtils;

import smile.Network;

/**
 * Simple goal re-estimation (filtering).
 * @author ik
 */
public class Experiment_1 {
    
    public static void main(String[] args) {
        Network origNet = new Network();
        origNet.readFile("../datasets/em_01_learned.xdsl");
        
        DBN net = new DBN(origNet, 10);
        
        //List<String> evidence = Arrays.asList("A", "A", "B", "A", "A", "C");
        //net.setDBNEvidence("O", evidence);
        
        net.setDBNEvidence("O", 0, "A");
        net.setDBNEvidence("O", 1, "A");
        net.setDBNEvidence("O", 2, "B");
        net.setDBNEvidence("O", 3, "A");
        net.setDBNEvidence("O", 4, "A");
        net.setDBNEvidence("O", 5, "C");
        // ... no evidence in slices 6 and 7 ...
        net.setDBNEvidence("O", 8, "A");
        
        net.getNet().updateBeliefs();
        
        // get probability of G
        Table<Integer, String, Double> probsG = net.getDBNNodeValuesTable("G");
        
        // print probability in node G over time
        Table<Integer, String, Double> result = HashBasedTable.create();
        result.putAll(probsG);
        GoogleUtils.printTable(result, System.out);
        
        MemChart.chart(net, "G");
    }
}
